package com.web.service.impl;

import java.util.Map;
import java.util.HashMap;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.web.dao.TWinNumDao;
import com.web.model.TWinNum;
import com.web.service.TWinNumService;
import com.web.utils.Pager;
import com.web.model.PageBean;
import com.web.model.constant.Constant;

/**
 * Service实现
 * 
 * @author wzy
 * 
 */
@Service
public class TWinNumServiceImpl implements TWinNumService {

	// protected Log log = LogFactory.getLog(getClass());
	@Autowired
	private TWinNumDao winNumDao;// 注入TWinNum的dao

	
	public int insert(TWinNum winNum) {
		return winNumDao.insert(winNum);
	}

	
	public int deleteByPrimaryKey(Long termCd) {
		return winNumDao.deleteByPrimaryKey(termCd);
	}

	
	public int updateByPrimaryKey(TWinNum winNum) {
		return winNumDao.updateByPrimaryKey(winNum);
	}

	
	public TWinNum selectByPrimaryKey(Long termCd) {
		return winNumDao.selectByPrimaryKey(termCd);
	}

	
	public List<TWinNum> selectList(Map<String, Object> map) {
		return winNumDao.selectList(map);
	}

	
	public PageBean<TWinNum> selectListByPage(Map<String, Object> map) {
		Pager.addPage(map);
		map.put("sort", "term_cd");
		map.put("order", Constant.ORDER_DESC);
		Integer count = winNumDao.selectListCount(map);
		List<TWinNum> list = winNumDao.selectList(map);
		PageBean<TWinNum> pageList = new PageBean<TWinNum>(list);
		pageList.setTotal(count);
		pageList.setList(list);
		pageList.setPageNum((Integer) map.get("pageNum"));
		pageList.setPageSize((Integer) map.get("pageSize"));
		pageList.setPages(Pager.getPages(count, (Integer) map.get("pageSize")));
		return pageList;
	}

	
	public TWinNum selectByModelSelective(TWinNum winNum) {
		return winNumDao.selectByModelSelective(winNum);
	}
	
	
	public int selectListCount(Map<String, Object> map){
		return winNumDao.selectListCount(map);
	}

	
	public void insertList(List<TWinNum> list) {
		// TODO Auto-generated method stub
		
	}
}
